<template>
  <div id="app"  v-bind:style="appDivStyle">
      <div class="context" ref="context">
          <!-- 条件查询区 -->
           <div class="queryBox" ref="queryBox">
                <el-form :model="formQueryCondition"
                         ref="form" size="mini">
                    <el-row>
                        <!-- 资产编号 -->
                        <el-col :span="5">
                            <el-form-item :label="$t('queryLabel.assetsAudit.assetCode')"   :label-width="queryformLabelWidth">
                                <el-input v-model.trim="formQueryCondition.assetId.val" class="queryItemStyle" clearable
                                        :placeholder="$t('queryLabel.assetsAudit.placeholderAssetCode')">
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <!-- 资产名称 -->
                        <el-col :span="5" :offset="1">
                            <el-form-item :label="$t('assetsAudit.queryLabel.assetName')"   :label-width="queryformLabelWidth">
                                <el-input v-model.trim="formQueryCondition.assetName.val" class="queryItemStyle" clearable
                                        :placeholder="$t('assetsAudit.queryLabel.placeholderAssetName')">
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <!-- 资产类型 -->
                        <el-col :span="5" :offset="1">
                            <el-form-item :label="$t('queryLabel.assetsAudit.assetsType')" :label-width="queryformLabelWidth">
                                <el-select v-model.trim="formQueryCondition.assetType.val" class="queryItemStyle" :placeholder="$t('queryLabel.selectOp')">
                                    <el-option :label="$t('shellAssets.label.all')" value=""></el-option>
                                    <el-option :value="item.valueCode" :key="item.valueCode" :label="item.valueText" v-for="item in assetTypeData"></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <!-- 演员 -->
                        <!-- <el-col :span="5" :offset="1">
                            <el-form-item :label="$t('assetsAudit.queryLabel.actor')"   :label-width="queryformLabelWidth">
                                <el-input v-model.trim="formQueryCondition.actor.val" class="queryItemStyle" clearable
                                        :placeholder="$t('assetsAudit.queryLabel.placeholderActor')">
                                </el-input>
                            </el-form-item>
                        </el-col> -->
                        <!-- 审核人 -->
                        <el-col :span="5" :offset="1">
                            <el-form-item :label="$t('queryLabel.assetsAudit.auditor')" :label-width="queryformLabelWidth">
                                <el-select v-model.trim="formQueryCondition.auditor.val" class="queryItemStyle" :placeholder="$t('queryLabel.selectOp')">
                                    <el-option :label="$t('shellAssets.label.all')" value=""></el-option>
                                    <el-option :value="item.name" :key="item.keyId" :label="item.name" v-for="item in auditorData"></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>

                            <!-- <el-form-item :label="$t('queryLabel.assetsAudit.updateTime')" :label-width="queryformLabelWidth">
                                <el-date-picker v-model.trim="formQueryCondition.updateTimeS.val" class="queryItemStyle" clearable
                                        :placeholder="$t('queryLabel.selectOp')" type="date" >
                                </el-date-picker>
                            </el-form-item>
                            <el-form-item :label="$t('queryLabel.timeTo')" :label-width="queryformLabelWidth">
                                <el-date-picker v-model.trim="formQueryCondition.updateTimeE.val" class="queryItemStyle" clearable
                                        :placeholder="$t('queryLabel.selectOp')" type="date" >
                                </el-date-picker>
                            </el-form-item> -->
                        <!-- 所属专区 -->
                        <el-col :span="5">
                            <el-form-item :label="$t('assetsAudit.assetSource')" :label-width="queryformLabelWidth">
                                <el-select v-model.trim="formQueryCondition.assetSource.val" class="queryItemStyle" :placeholder="$t('queryLabel.selectOp')">
                                    <el-option :label="$t('shellAssets.label.all')" value=""></el-option>
                                    <el-option :value="item.keyId" :key="item.keyId" :label="item.speAreaName" v-for="item in assetSourceData"></el-option>
                                    <!-- <el-option :label="$t('shellAssets.label.shellAssetsSource1')" :value="$t('shellAssets.label.shellAssetsSource1')"></el-option>
                                    <el-option :label="$t('shellAssets.label.shellAssetsSource2')" :value="$t('shellAssets.label.shellAssetsSource2')"></el-option>
                                    <el-option :label="$t('shellAssets.label.shellAssetsSource3')" :value="$t('shellAssets.label.shellAssetsSource3')"></el-option>
                                    <el-option :label="$t('shellAssets.label.shellAssetsSource4')" :value="$t('shellAssets.label.shellAssetsSource4')"></el-option>
                                    <el-option :label="$t('shellAssets.label.shellAssetsSource5')" :value="$t('shellAssets.label.shellAssetsSource5')"></el-option>
                                    <el-option :label="$t('shellAssets.label.shellAssetsSource6')" :value="$t('shellAssets.label.shellAssetsSource6')"></el-option>
                                    <el-option :label="$t('shellAssets.label.shellAssetsSource7')" :value="$t('shellAssets.label.shellAssetsSource7')"></el-option> -->
                                </el-select>
                            </el-form-item>
                        </el-col>
                            <!-- 审核时间起 -->
                        <el-col :span="5" :offset="1">
                            <el-form-item :label="$t('assetsAudit.auditTime')" :label-width="queryformLabelWidth" >
                                <el-date-picker v-model.trim="formQueryCondition.auditTimeS.val" class="queryItemStyle" clearable
                                        :placeholder="$t('queryLabel.selectOp')" type="date" >
                                </el-date-picker>
                            </el-form-item>
                        </el-col>
                        <!-- 审核时间止 -->
                        <el-col :span="5" :offset="1">
                            <el-form-item :label="$t('queryLabel.timeTo')" :label-width="queryformLabelWidth">
                                <el-date-picker v-model.trim="formQueryCondition.auditTimeE.val" class="queryItemStyle" clearable
                                        :placeholder="$t('queryLabel.selectOp')" type="date" >
                                </el-date-picker>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <!-- <el-form-item :label="$t('assetsAudit.queryLabel.auditStatus')" :label-width="queryformLabelWidth">
                        <el-select v-model.trim="formQueryCondition.assetState.val" class="queryItemStyle" :placeholder="$t('queryLabel.selectOp')">
                            <el-option :label="$t('shellAssets.label.all')" value=""></el-option>
                            <el-option :value="item.valueCode" :key="item.valueCode" :label="item.valueText" v-for="item in approvalStatusData"></el-option>
                        </el-select>
                    </el-form-item> -->
                    <el-row>
                        <el-col :span="24">
                            <div style="text-align:right">
                                <!-- <el-form-item>
                                    <el-button type="primary" @click="onRecord" icon="el-icon-document" :loading="loading">{{ $t('btnText.auditRecordBtnText') }}</el-button>
                                </el-form-item>
                                <el-form-item>
                                    <el-button type="primary" @click="onExport" icon="el-icon-download" :loading="loading">{{ $t('btnText.auditRecordExportBtnText') }}</el-button>
                                </el-form-item> -->
                                <el-form-item>
                                    <el-button v-permission="{menuCode: menuCode, resourceCode: 'resetBtnText'}"
                                    type="primary" @click="onReset('form')">{{ $t('btnText.resetBtnText') }}</el-button>
                                <!-- </el-form-item> -->
                                <!-- <el-form-item> -->
                                    <el-button v-permission="{menuCode: menuCode, resourceCode: 'queryBtnText'}"
                                    type="primary" @click="onQuery('queryBtnText')" icon="el-icon-search" :loading="loading">{{ $t('btnText.queryBtnText') }}</el-button>
                                </el-form-item>

                            </div>
                        </el-col>
                    </el-row>

                </el-form>
            </div>

            <!-- 数据展示区 -->
            <div class="dataBox" ref="dataBox">

                <el-table v-if="isInit" ref="singleTable"
                            :data="tableData"
                            :height="tableHeight"
                            @sort-change="sortChange"
                            v-loading="loading" size="mini"
                            style="width: 100%;" stripe=stripe border=border>
                    <el-table-column type="index"  width="70" fixed="left"
                        :label="$t('table.xh')" align="center">
                    </el-table-column>
                    <el-table-column width="260" fixed="left"
                        :label="$t('table.op')" align="center">
                        <template slot-scope="scope">
                            <el-button  size="gv" icon="el-icon-tickets"
                                 :loading="loading" @click="onDetails(scope.$index, scope.row,'detailsBtnText')"
                                 v-permission="{menuCode: menuCode, resourceCode: 'detailsBtnText'}"
                                    >{{ $t('assetsAudit.btnText.detailsBtnText') }}</el-button>
                            <el-button size="gv" icon="el-icon-edit" :disabled="scope.row.assetStateByQuery != 'PendingReview'"
                                 :loading="loading" @click="onAudit(scope.$index, scope.row,'auditingBtnText')"
                                 v-permission="{menuCode: menuCode, resourceCode: 'auditingBtnText'}"
                                    >{{ $t('assetsAudit.btnText.assetsAuditBtnText') }}</el-button>
                            <el-button size="gv" icon="el-icon-edit"
                                 :loading="loading" @click="onSubAssets(scope.$index, scope.row)"
                                 v-permission="{menuCode: menuCode, resourceCode: 'subAssetBtnText'}"
                                    >{{ $t('assetsAudit.btnText.subAssetsBtnText') }}</el-button>
                        </template>
                    </el-table-column>
                    <el-table-column prop="assetCode" min-width="130" fixed="left"
                        :label="$t('assetsAudit.table.assetCode')" sortable="custom" sort-by="assetCode">
                    </el-table-column>
                    <el-table-column prop="assetName" min-width="200" fixed="left"
                        :label="$t('assetsAudit.assetName')" sortable="custom" sort-by="assetName">
                    </el-table-column>
                    <el-table-column prop="speAreaName" min-width="110" sortable="custom" sort-by="speAreaName"
                        :label="$t('table.assetsAudit.source')" >
                    </el-table-column>
                    <!-- <el-table-column prop="assetsType" min-width="110"
                        :label="$t('table.assetsAudit.assetsType')" sortable="custom" sort-by="name">
                    </el-table-column>
                    <el-table-column prop="moreInfo" min-width="110"
                        :label="$t('table.assetsAudit.moreInfo')" sortable="custom" sort-by="code">
                    </el-table-column> -->
                    <el-table-column prop="assetState" min-width="110"
                        :label="$t('assetsAudit.auditStatus')" sortable="custom" sort-by="assetState">
                    </el-table-column>

                    <el-table-column prop="assetType" min-width="110"
                        :label="$t('assetsAudit.table.assetType')" sortable="custom" sort-by="assetType">
                    </el-table-column>
                    <el-table-column  min-width="110" prop="modifier"
                        :label="$t('assetsAudit.table.auditor')" sortable="custom"  sort-by="modifier">
                    </el-table-column>

                    <!-- <el-table-column prop="updateTime" min-width="180"
                        :label="$t('table.assetsAudit.updateTime')" sortable="custom" sort-by="name">
                    </el-table-column> -->
                    <el-table-column prop="lastUpdatedDate" min-width="180"
                        :label="$t('assetsAudit.auditTimeLast')" sortable="custom" sort-by="lastUpdatedDate">
                    </el-table-column>
                    <!-- <el-table-column prop="auditor" min-width="120"
                        :label="$t('table.assetsAudit.auditor')" sortable="custom" sort-by="name">
                    </el-table-column>                   -->
                </el-table>


            </div>
        </div>

        <!-- 翻页选择区 -->
        <div class="pageBox">
            <el-pagination @size-change="sizeChange"
                            @current-change="currentPageChange"
                            :current-page="pager.curPage"
                            :page-sizes="pager.sizes"
                            :page-size="pager.curSize"
                            :background="true"
                            layout="total, sizes, prev, pager, next, jumper" :total="pager.total">
            </el-pagination>
        </div>

         <!--详情对话框-->
        <el-dialog :title="$t('label.dialogDetails')" :visible.sync="isShowInfoForm" top="5vh" width="60%" @close="renewRecord" :close-on-click-modal="false">
            <el-tabs v-model="activeName" type="border-card" @tab-click="handleClick">
                <el-tab-pane :label="$t('assetsAudit.assetInfo')" name="first">
                    <assets-info :datas="dataForm"></assets-info>
                </el-tab-pane>
                <el-tab-pane :label="$t('assetsAudit.actorInformation')" name="second">
                    <actor-info :datas="actorData"></actor-info>
                </el-tab-pane>
                <!-- <el-tab-pane :label="$t('assetsAudit.auditRecord')" name="third">
                    <audit-record :datas="reviewQueryCondition" ref="auditRecord"></audit-record>
                </el-tab-pane> -->
            </el-tabs>
        </el-dialog>

         <!--审核对话框-->
        <el-dialog :title="$t('assetsAudit.auditing')" :visible.sync="isShowEditForm" @close="closeDialog" top="5vh" width="60%" :close-on-click-modal="false">
            <el-form :model="editForm" ref="editForm" size="mini"
                     :label-position="editFormPosition" status-icon=status-icon :rules="editRules">
                <el-form-item :label="$t('assetsAudit.auditSuggestion')" :label-width="editformLabelWidth" prop="reviewDesc">
                    <el-input v-model.trim="editForm.reviewDesc" type="textarea" :rows="2"  :placeholder="$t('label.pleaseInput')">></el-input>
                </el-form-item>
                <el-form-item  :label-width="editformLabelWidth" >
                    <el-button size="mini" type="primary"  @click="submitFormForPass(currentResCode)" :loading="loading">{{$t('assetsAudit.pass')}}</el-button>
                    <el-button size="mini" type="primary"  @click="submitFormForReject('editForm',currentResCode)" :loading="loading">{{$t('assetsAudit.reject')}}</el-button>
                    <el-button size="mini" type="primary"  @click="submitFormForDiscard" :loading="loading">{{$t('assetsAudit.discard')}}</el-button>
                    <el-button size="mini" @click="isShowEditForm = false" :loading="loading">{{ $t('btnText.cancelBtnText') }}</el-button>
                </el-form-item>
            </el-form>
        </el-dialog>

  </div>


</template>

<script>

import comBaseVue from '../../baseViewModel';
import subAssetsInfo from  './SubAssetsInfo';
import assetsInfo from  './AssetsInfo';
import actorInfo from  './ActorInfo';
import auditRecord from  './AuditRecord';
import Vue from 'vue';
import { debug } from 'util';

export default {
  mixins: [comBaseVue],
  name:'AssetsAudit',
  props:{
      menuCode: String,
  },
  data () {

    return {
        isShowInfoForm: false,
        // isShowEditForm: false,
        // isAuditInfoForm: false,
        activeName: 'first',
        isInit:false,
        tableHeight:100,
        auditorData:[],
        assetTypeData:[],
        assetSourceData:[],
        approvalStatusData:[],
        actorData:[],
        appDivStyle:{
            height:this.$store.getters.appHeight,
        },
        modelName:"com.ispr.iptv.entity.media.AssetEntity",
        modelName2:"com.ispr.iptv.entity.media.VAssetEntity",//操作的实体类F
        // 查询条件
        formQueryCondition: {
            assetId: {
                key: 'assetCode',
                op: 'LIKE',
                val: ''
            },
            assetName: {
                key: 'assetName', // 操作符
                op: 'LIKE', // 操作符
                val: '' // 查询的值
            },
            auditor: {
                key: 'modifier', // 操作符
                op: '=', // 操作符
                val: '' // 查询的值
            },
            // actor:{
            //    key:'assetAndActorList.mediaActor.actorName',
            //    op:'LIKE',
            //    val:''
            // },
            // profession:{
            //    key:'assetAndActorList.profession',
            //    op:'LIKE',
            //    val:'Actor'
            // },
            assetType: {
                key: 'assetType', // 操作符
                op: '=', // 操作符
                val: '' // 查询的值
            },
            isEnable: {
                key: 'isEnable', // 操作符
                op: '=', // 操作符
                val: 'Available' // 查询的值
            },
            // updateTimeS: {
            //     key: 'lastUpdatedDate', // 操作符
            //     op: '>=', // 操作符
            //     val: '' // 查询的值
            // },
            // updateTimeE: {
            //     key: 'lastUpdatedDate', // 操作符
            //     op: '<=', // 操作符
            //     val: '' // 查询的值
            // },
            auditTimeS: {
                key: 'lastUpdatedDate', // 操作符
                group: 'auditTimeS',
                op: '>=', // 操作符
                val: '' // 查询的值
            },
            auditTimeE: {
                key: 'lastUpdatedDate', // 操作符
                group: 'auditTimeE',
                op: '<=', // 操作符
                val: '' // 查询的值
            },
            assetSource: {
                key: 'assetSource', // 操作符
                op: '=', // 操作符
                val: '' // 查询的值
            },
            assetState: {
                key: 'assetState',
                op: '=',
                val: 'PendingReview'
            },
            isPendingreview: {
                key: 'isPendingreview',
                op: '=',
                val: 'YES',
                group: 'assetState'
            },

        },

        // 审核面板绑定的对象
        editForm: {
            keyId: "",
            version: 0,
            assetVersion: "",
            reviewDataId: "",
            reviewDataType: "",
            isEnable: "",
            approvalStatus: "",
            reviewDesc: "",
        },
        // 编辑面板的验证规则
        editRules: {
            reviewDesc: [{ required: true, message: this.$i18n.t('assetsAudit.rules.auditSuggestion'), trigger: 'blur' }],
        },

        dataForm: {
            /**资产详情 */
            keyId: 0,
            version: 0,
            assetId: "",
            assetName: "",
            assetType: "",
            assetSource: "",
            firstCategory: "",
            secondCategory: "",
            classification: "",
            year: "",
            area: "",
            language: "",
            director: "",
            actor: "",
            assetScriptwriter: "",
            assetDescription: "",
            score: "",
            licenseNo: "",
            auditStatus: "",
            createTime: "",
            auditTimeLast: "",
            cpId: "",
            authorizer: "",
            crtDesc: "",
            crtArea: "",
            crtStartTime: "",
            crtEndTime: "",
            copyrightBegin: "",
            copyrightEnd: "",
            copyrightType: "",
            copyrightRemark: "",
        },
        actorQueryCondition: {
            code: {
                key: 'actorCode',
                op: '=', // 操作符
                val: ''
            },
        },
        reviewQueryCondition: {
            code: {
                key: 'reviewDataId',
                op: '=', // 操作符
                val: ''
            },
            type: {
                key: 'reviewDataType',
                op: '=', // 操作符
                val: ''
            },
            assetName: {
                key: 'assetName',
                op: '=',
                val: ''
            },

        },


    }
  },
  watch:{
      tableHeight:function(val){
        //   alert(val);
      },
      isInit:function(val){
        //   alert(val);
      }
  },
  methods:{
    // 查询按钮
    onQuery: function(rescode) {
      this.currentResCode = (rescode && rescode!=='') ? rescode : '';
        if(this.formQueryCondition.auditTimeS.val!=null
        && this.formQueryCondition.auditTimeS.val!=""){
            this.formQueryCondition.auditTimeS.val=this.formatDate(this.formQueryCondition.auditTimeS.val);
        }
        if(this.formQueryCondition.auditTimeE.val!=null
        && this.formQueryCondition.auditTimeE.val!=""){
            this.formQueryCondition.auditTimeE.val=this.formatDate(this.formQueryCondition.auditTimeE.val);
        }
        this.pager.curPage = 1;
        this.queryTable();
    },
        // 查询网格数据
        queryTable: function() {
            this.loading = true;
            this.queryModel(this.modelName2,"Query",this.formQueryCondition,this.pager,this.sort,this.setTableData)
        },

     // 查询网格数据
    // queryTable: function(rescode) {
    //   this.currentResCode = (rescode && rescode!=='') ? rescode : '';
    //     this.loading = true;
    //     this.auditConfirmQuery("/api/mediaAudit/audit",this.modelName,"Query",this.formQueryCondition,this.pager,this.sort,this.setTableData);
    // },

     // 重置
    onReset:function(){
        if (this.$refs['form']) {
            this.$refs['form'].resetFields();
        }
        this.formQueryCondition.assetId.val = "";
        this.formQueryCondition.assetName.val = "";
        this.formQueryCondition.auditor.val = "";
        // this.formQueryCondition.actor.val = "";
        // this.formQueryCondition.actor.val = "";
        this.formQueryCondition.assetType.val = "";
        // this.formQueryCondition.updateTimeS.val = "";
        // this.formQueryCondition.updateTimeE.val = "";
        this.formQueryCondition.auditTimeS.val = "";
        this.formQueryCondition.auditTimeE.val = "";
        this.formQueryCondition.assetSource.val = "";
        // this.formQueryCondition.assetState.val = "PendingReview";
    },

    //审核人下拉列表数据
    findAuditor: function(){
        var queryRequest = {
                className: "com.ispr.iptv.entity.sys.SysUser",//修改为被查询的实体地址
                opKey: "Query",//后台编写相应的接口实现方法，主要负责转化类型
                params: [{key: 'isEnable',op: '=',val: 'Available'}],
                userInfo: this.getUserInfo()
            };
            var _this = this;
            this.axios.post('/api/query', queryRequest, {headers: this.headersObj})
                .then(function(res) {
                    // alert(JSON.stringify(res));
                    // alert(res.data.code);
                    if (res.data.code == "SUCCESS") {
                        _this.auditorData = [];
                        for (var i = 0; i < res.data.data.length; i++) {
                            _this.auditorData.push(res.data.data[i]);
                        }
                    } else {
                        // this.$message.error(this.$i18n.t("errorCode." + json.reason,json.message));
                    }
                })
                .catch(function(error) {
                    console.log(error);
                    // this.$message.error(this.$i18n.t("errorCode." + json.reason,json.message));
                });
    },

    //资产类型下拉列表数据
    findAssetType: function(){
        this.findByTypeCode("10005",this.setAssetTypeCallback);
    },

    setAssetTypeCallback: function(isSuccess,json){
        try{
            if (isSuccess) {
                for (var i = 0; i < json.data.length; i++) {
                    this.assetTypeData.push(json.data[i]);
                }
            }
            else {
                this.$message.error(json.msg);
            }
        }
        catch(e){
            alert(e);
        }
    },

    //资产来源下拉列表数据
    // findAssetSource: function(){
    //     this.findByTypeCode("10008",this.setAssetSourceCallback);
    // },

    // setAssetSourceCallback: function(isSuccess,json){
    //     try{
    //         if (isSuccess) {
    //             for (var i = 0; i < json.data.length; i++) {
    //                 this.assetSourceData.push(json.data[i]);
    //             }
    //         }
    //         else {
    //             this.$message.error(this.$i18n.t("errorCode." + json.reason,json.message));
    //         }
    //     }
    //     catch(e){
    //         alert(e);
    //     }
    // },
    findAssetSource: function(){
      var queryRequest = {
        className: "com.ispr.iptv.entity.sys.SpeArea",//修改为被查询的实体地址
        opKey: "Query",//后台编写相应的接口实现方法，主要负责转化类型
        params: [{key: 'isEnable',op: '=',val: 'Available'}],
        userInfo: this.getUserInfo()
      };
      var _this = this;
      this.axios.post('/api/query', queryRequest, {headers: this.headersObj})
      .then(function(res) {
      // alert(JSON.stringify(res));
      // alert(res.data.code);
        if (res.data.code == "SUCCESS") {
          _this.assetSourceData = [];
          for (var i = 0; i < res.data.data.length; i++) {
          _this.assetSourceData.push(res.data.data[i]);
          }
        } else {
        this.$message.error(json.msg);
        }
      })
      .catch(function(error) {
      console.log(error);
      // this.$message.error(this.$i18n.t("errorCode." + json.reason,json.message));
      });
    },


    //审核状态下拉列表数据
    findApprovalStatus: function(){
        this.findByTypeCode("10007",this.setApprovalCallback);
    },

    setApprovalCallback: function(isSuccess,json){
        try{
            if (isSuccess) {
                for (var i = 0; i < json.data.length; i++) {
                    this.approvalStatusData.push(json.data[i]);
                }
            }
            else {
                this.$message.error(json.msg);
            }
        }
        catch(e){
            alert(e);
        }
    },



    tableRowClassName({row, rowIndex}) {
        if (rowIndex === 1) {
          return 'warning-row';
        } else if (rowIndex === 3) {
          return 'success-row';
        }
        return '';
    },

    // 授权按钮单击事件
    editMenu: function(index, row) {

    },

     // 审核记录
    onRecord: function(index, row) {

    },

     // 审核记录导出
    onExport: function(index, row) {

    },

     // 资产审核按钮单击事件
    onAudit: function(index, row,rescode) {
        this.currentResCode = (rescode && rescode!=='') ? rescode : '';
        // alert(row.keyId);
        this.editForm.assetVersion = row.version;
        this.editForm.reviewDesc = "";
        this.editForm.reviewDataId= row.keyId,
        this.editForm.reviewDataType= "ASSET",
        this.editForm.isEnable= "Available",
        this.isShowEditForm = true;
    },

    closeDialog: function(){
          this.$refs['editForm'].resetFields();
    },

    renewRecord: function(){
        this.activeName = "first";
    },
    //通过
    submitFormForPass: function (rescode) {
      this.currentResCode = (rescode && rescode!=='') ? rescode : '';
        this.editForm.approvalStatus= "ExaminationPassed",
        this.loading = true;
        this.procCommand("MediaAuditProc",
        "com.ispr.iptv.entity.media.AssetEntity",
        "Default",
        {
            "keyId":this.editForm.reviewDataId,
            "version":this.editForm.assetVersion,
            "assetState":this.editForm.approvalStatus,
            "reviewHisEntity":this.editForm
        },
        null,
        this.commonCallback);
    },
    //驳回
    submitFormForReject: function (formName,rescode) {
      this.currentResCode = (rescode && rescode!=='') ? rescode : '';
        var _this = this;
        this.editForm.approvalStatus= "TheAuditFailed",
        this.$refs[formName].validate(function (valid) {
            if (valid) {
                _this.loading = true;
                // _this.procCommand("SaveNewReturnPK",
                // "com.ispr.iptv.entity.audit.ReviewHisEntity",
                // "Default",
                // _this.editForm,
                // _this.submitFormCallback);

                _this.procCommand("MediaAuditProc",
                "com.ispr.iptv.entity.media.AssetEntity",
                "Default",
                {
                    "keyId":_this.editForm.reviewDataId,
                    "version":_this.editForm.assetVersion,
                    "assetState":_this.editForm.approvalStatus,
                    "reviewHisEntity":_this.editForm
                },
                null,
                _this.commonCallback);

                // _this.mediaAudit("com.ispr.iptv.service.impl.MediaAuditServiceImpl",this.editForm,{
                //         "keyId":this.editForm.reviewDataId,
                //         "version":this.editForm.assetVersion,
                //         "assetState":this.editForm.opType
                //     },this.commonCallback);
            } else {
                return false;
            }
        });
    },
    //废弃
    submitFormForDiscard: function(){
        this.editForm.approvalStatus= "Discard",
        this.loading = true;
        this.procCommand("MediaAuditProc",
        "com.ispr.iptv.entity.media.AssetEntity",
        "Default",
        {
            "keyId":this.editForm.reviewDataId,
            "version":this.editForm.assetVersion,
            "assetState":this.editForm.approvalStatus,
            "reviewHisEntity":this.editForm
        },
        null,
        this.commonCallback);
    },

    // 执行命令后的回调函数
    // submitFormCallback: function submitFormCallback(isSuccess,json) {
    //     this.loading = false;
    //     if(isSuccess){
    //         this.isShowEditForm = false;
    //         // 修改资产表的资产状态
    //         this.procCommand("PartialUpdateProc",
    //         "com.ispr.iptv.entity.media.AssetEntity",
    //         "Default",
    //         {
    //             "keyId":this.editForm.reviewDataId,
    //             "version":this.editForm.assetVersion,
    //             "assetState":this.editForm.opType},
    //         this.commonCallback);
    //     }
    //     else
    //     {
    //         this.$message({
    //                         message: this.$i18n.t("errorCode." + json.reason),
    //                         type: 'warning'
    //                         });
    //     }
    // },

    commonCallback: function (isSuccess,json) {
        this.loading = false;
        this.isShowEditForm = false;
        if(isSuccess){
            this.$message({
                message: this.$i18n.t("message.successTip"),//resource.message.successTip,
                type: 'success'
            });
            this.queryTable();
        }
        else
        {
            this.$message({
                            message: json.msg,
                            type: 'warning'
                            });
        }
    },

    // 跳转到子资产
    onSubAssets: function(index, row) {
         this.$parent.setCurrentComponent("SubAssets",{curProps:row.keyId,isNeedGoBack:true,menuCode:this.menuCode });
        // this.queryModel("com.ispr.iptv.entity.media.SubAssetEntity","Query",{
        //         assetId: {key: 'assetId',op: '=',val: row.keyId}
        //     },this.pager,this.sort,this.subAssetsCallback);
    },

    /** */
    // subAssetsCallback: function(isSuccess,json) {
    //     if(isSuccess){
    //         this.tableDatas = [];
    //         var queryResult = json.list;
    //         for (var i = 0; i < queryResult.length; i++) {
    //             this.tableDatas.push(queryResult[i]);
    //         }

    //     }

    // },

     // 查看详情按钮单击事件
    onDetails: function(index, row,rescode) {
        this.currentResCode = (rescode && rescode!=='') ? rescode : '';
        //dataAccess.queryDomainModelByKeyID(this, modelName, "Query", row.keyID, true, this.$options.methods.editCallback);
        this.queryModelByKeyID(this.modelName,row.keyId,"Query",this.detailsCallback);
        // this.actorQueryCondition.code.val = "1006";
        this.reviewQueryCondition.code.val = row.keyId;//资产id
        this.reviewQueryCondition.type.val = "ASSET";
        this.reviewQueryCondition.assetName.val = row.assetName;
        // this.queryModelByKeyID("com.ispr.iptv.entity.media.MediaActor","","Query",this.actorDetailsCallback);
   },

    // 资产详情按钮回调事件
    detailsCallback: function(isSuccess,json) {
        // if (this.$refs['dataForm']) {
            //     this.$refs['dataForm'].resetFields();
        // }

        if(isSuccess){
            //this.curCommand = "UpdateProc";
            this.isShowInfoForm = true;
            this.dataForm = json;
            if(json.assetYear!=null && json.assetYear!="" && json.assetYear!="NaN"){
                this.dataForm.assetYear=json.assetYear;
            }else{
                this.dataForm.assetYear="";
            }
            var actor = "";
            var edit ="";
            var director = "";
            json.assetAndActorList.forEach(element =>{
                    var A = "";
                    if(element.profession == "导演"){
                        //element.profession == "director"
                        A = element.actorName;
                        if(director == ""){
                            director = A;
                        }else{
                            director = director+","+ A;
                        }
                    }else if(element.profession == "编剧"){
                        //element.profession == "screenwriter"
                        A = element.actorName;
                        if(edit == ""){
                            edit = A;
                        }else{
                            edit = edit+","+ A;
                        }
                    }else if(element.profession == "演员"){
                        //element.profession == "actor"
                        A = element.actorName;
                        if(actor == ""){
                            actor = A;
                        }else{
                            actor = actor+","+ A;
                        }
                    }
                })
            this.dataForm.director = director;//"导演",
            this.dataForm.adaptor = edit;//"编剧",
            this.dataForm.actor = actor;//"演员",

            this.dataForm.tagNameAll = "";
            let temp = "";
            json.assetAndTagList.forEach(element =>{
                if(temp==""){
                    temp = element.tagName;
                }else{
                    temp = element.tagName + "," + temp;
                }
            });
            this.dataForm.tagNameAll = temp;
        }else{
            this.$message({
                message: json.msg,
                type: 'warning'
                });
        }
    },
    // 演员详情按钮回调事件
    actorDataCallback: function(isSuccess,json) {

        if(isSuccess){
            this.actorData = json;
        }
        else{
            this.$message({
                message: json.msg,
                type: 'warning'
                });
        }
    },

    // queryTable: function() {
    //   this.loading = true;
    //   this.queryModel(
    //     this.modelName,
    //     "Query",
    //     this.dataForm.actor,
    //     this.pager,
    //     this.sort,
    //     this.setTableData
    //   );
    // },

    handleClick(tab, event) {
        if(tab.name=="second"){
            this.procCommand("QueryActorFromMiddleProc",
            "com.ispr.iptv.entity.media.AssetAndActor",
            "Default",
            {
                "keyId":this.reviewQueryCondition.code.val
            },
            null,
            this.actorDataCallback);
            // this.actorData = "";
        }else if(tab.name=="third"){
            this.$refs.auditRecord.onQuery();
        }
    },
    initTable:function(){
        this.tableHeight = this.$refs.context.offsetHeight - this.$refs.queryBox.offsetHeight;
        this.isInit = true;
    },
    enterDown(){
        var g = this
        if(g.isShowEditForm){
          g.submitFormForPass(g.currentResCode)
        }else if(g.isShowInfoForm){
            // 详情
            g.isShowInfoForm = false;
        }else if(!g.loading){
          g.onQuery()
        }
    }
  },
  mounted: function mounted() {
    this.findAuditor();
    this.findAssetType();
    this.findAssetSource();
    this.findApprovalStatus();

    this.onQuery();
    window.setTimeout(this.initTable,100);

  },
  components: {
    "sub-assets-info": subAssetsInfo,
    "actor-info": actorInfo,
    "assets-info": assetsInfo,
    "audit-record": auditRecord,
  },
  activated: function() {
     this.onQuery();
  },
}

</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.separateStyle{
    margin-left: 20px;
}
</style>
